<admintpl file="header" />
</head>
<body>
<div class="wrap js-check-wrap">
    <ul class="nav nav-tabs">
        <li class="active"><a href="javascript:;">内部推广人员</a></li>
        <li><a href="{:U('Promoters/add')}" target="_self">添加</a></li>
    </ul>
    <form class="well form-search" method="post" action="{:U('Promoters/index')}">
        关键字：
        <input type="text" name="keyword" style="width: 200px;" value="{$keyword|default=''}" placeholder="请输入姓名或手机号">
        <label for="exampleInputName2">状态</label>
        <select class="form-control" style="height: 35px;" name="status">
            <option value="0">请选择状态</option>
            <option value="1"<if condition="$status eq 1">selected</if> >正常</option>
            <option value="2"<if condition="$status eq 2">selected</if> >禁用</option>
        </select>
        <input type="submit" class="btn btn-primary" value="搜索" />
        <a class="btn btn-danger" href="{:U('Promoters/index')}">清空</a>
    </form>
    <form class="js-ajax-form" action="" method="post">
        <table class="table table-hover table-bordered table-list">
            <thead>
            <tr>
                <th>编号</th>
                <th>姓名</th>
                <th>手机号</th>
                <th>职务</th>
                <th>添加时间</th>
                <th>更新时间</th>
                <th>状态</th>
                <th>操作</th>
            </tr>
            </thead>
            <tbody>
            <volist name="list" id ="sto">
                <tr>
                    <td>{$sto.id}</td>
                    <td>{$sto.user_name}</td>
                    <td>{$sto.phone_mob}</td>
                    <td>{$sto.post|default='无'}</td>
                    <td>{$sto.create_time|date="Y-m-d H:i",###}</td>
                    <td>
                        <if condition="$sto['update_time']">
                            {$sto.update_time|date="Y-m-d H:i",###}
                            <else/>
                            无
                        </if>
                    </td>
                    <td>
                        <if condition="$sto.status eq 1">
                            <a href="javascript:;" class="btn btn-success cancelStatus" data-id="{$sto.id}">正常</a>
                            <elseif condition="$sto.status eq 2" />
                            <a href="javascript:;" class="btn btn-danger confirmStatus" data-id="{$sto.id}">禁用</a>
                        </if>
                    </td>
                    <td>
                        <a type="button" class="btn btn-default" href="{:U('Promoters/edit',array('id'=>$sto['id']))}">编辑</a>
                        <a class="btn btn-danger delete" data-id="{$sto.id}" href="javescript:;{:U('Promoters/delete',array('id'=>$sto['id']))}">删除</a>
                        <a type="button" class="btn btn-success" href="{:U('Promoters/statistics',array('id'=>$sto['user_id']))}">查看邀请明细</a>
                    </td>
                </tr>
            </volist>
            </tbody>
        </table>
        <div class="pagination">{$page}</div>
    </form>
</div>
<script src="__PUBLIC__/js/common.js"></script>
<script src="__PUBLIC__/layer/layer.js"></script>
<!-- iframe自适应高度 -->
</body>
<script type="text/javascript">
    //禁用
    var url = "{:U('Promoters/updateStatus')}";
    $(".cancelStatus").click(function(){
        var id = $(this).attr('data-id');
        layer.confirm('您确定要禁用这个推广人员么？', {
            btn: ['是','否'] //按钮
        }, function(){
            $.post(url,{
                id:id,
                status:2
            },function(data){
                var res = JSON.parse(data);
                if(res.code == 1){
                    layer.msg(res.msg,function(){
                        window.location.reload();
                    });
                }else{
                    layer.msg('操作失败！');
                    return false;
                }
            })
        });
    });
    //正常
    $(".confirmStatus").click(function(){
        var id = $(this).attr('data-id');
        layer.confirm('您确定要启用这个推广人员么？', {
            btn: ['是','否'] //按钮
        }, function(){
            $.post(url,{
                id:id,
                status:1
            },function(data){
                var res = JSON.parse(data);
                if(res.code == 1){
                    layer.msg(res.msg,function(){
                        window.location.reload();
                    });
                }else{
                    layer.msg('操作失败！');
                    return false;
                }
            })
        });
    })
    //删除
    $(".delete").click(function(){
        var id = $(this).attr("data-id");
        var deleteUrl = "{:U('Promoters/delete')}";
        layer.confirm('您确定要删除这个推广人员么？', {
            btn: ['是','否'] //按钮
        }, function(){
            $.post(deleteUrl,{
                id:id,
            },function(data){
                var res = JSON.parse(data);
                if(res.code == 1){
                    layer.msg(res.msg,function(){
                        window.location.reload();
                    });
                }else{
                    layer.msg('操作失败！');
                    return false;
                }
            })
        });
    })

    //查看统计信息
    $(".detail").click(function(){
        var store_id = $(this).attr('data-id');
        var url = "{:U('Store/postData')}";
        $.post(url,{
            store_id:store_id
        },function(data){
            var res = JSON.parse(data);
            if(res.code == 1){
                $.each(res.list,function(index,item){

                })
                layer.open({
                    type: 1,
                    skin: 'layui-layer-rim', //加上边框
                    area: ['420px', '240px'], //宽高
                    content: 'html内容'
                });
            }else{
                layer.msg('暂无数据');
                return false;
            }
        })
    })
</script>

</html>
